<template>
	<el-container>
		<div class="right-panel">
			<div class="right-panel-search" style="width: 100%; margin-top: 5px; margin-bottom: 5px">
				<div class="panel-search-box">
					<span class="demonstration" style="margin-left: 10px">标题:</span>
					<el-input v-model="search.title" placeholder="请输入标题	" style="margin-left: 10px; width: 180px"
						clearable></el-input>
				</div>
				<div class="panel-search-box">
					<span class="demonstration" style="margin-left: 10px">类型:</span>
					<el-input v-model="search.type" placeholder="请输入类型	" style="margin-left: 10px; width: 180px"
						clearable></el-input>
				</div>
				<div class="panel-search-box">
					<el-button type="primary" style="margin-left: 10px" @click="upsearch">查询</el-button>
					<el-button type="" @click="cleanSearch">清空</el-button>
				</div>
			</div>
		</div>
		<el-header style="display: none"></el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" :params="params" border stripe remoteSort remoteFilter
				@selection-change="selectionChange">
				<!-- <el-table-column type="selection" width="50"></el-table-column> -->

				<el-table-column label="标题" prop="title" align="center" min-width="150"></el-table-column>
				<el-table-column label="类型" prop="type" align="center" min-width="280"></el-table-column>
				<el-table-column label="成功条数" prop="successNum" align="center" min-width="150"></el-table-column>
				<el-table-column label="失败条数" prop="errorNum" align="center" min-width="150"></el-table-column>
				<el-table-column label="创建时间" align="center" min-width="150">
					<template #default="scope">
						{{ this.$TOOL.dateFormat(scope.row.createTime, 'yyyy 年 MM 月 dd 日 hh:mm:ss') }}
					</template>
				</el-table-column>
			</scTable>
		</el-main>
		<!-- <el-drawer v-model="tasksVisible" :size="450" title="任务中心" destroy-on-close>
			<tasks></tasks>
		</el-drawer> -->
	</el-container>
</template>

<script>
export default {
	name: 'execLog',
	data() {
		return {
			dialog: {
				info: false
			},
			search: {},
			apiObj: this.$API.log.list,
			params: {}
		}
	},
	watch: {
		groupFilterText(val) {
			this.$refs.group.filter(val)
		}
	},

	mounted() { },
	async created() { },
	methods: {
		//任务
		downTemp() {
			// 下载模板
		},
		//编辑
		table_edit(row) {
			this.dialog.edit = true
			this.$nextTick(() => {
				this.$refs.editDialog.open('edit').setData(row)
			})
		},
		//表格内开关
		async changeSwitch(val, row) {
			row.enable = row.enable === 1 ? 0 : 1
			row.$switch_status = true
			let data = {
				enable: val,
				staffNumber: row.staffNumber
			}
			var res = await this.$API.user.user.enable.post({ data: data })
			if (res && res.code === 0) {
				setTimeout(() => {
					delete row.$switch_status
					row.enable = val
					// console.log(typeof val, row)
					this.$message.success('操作成功')
				}, 500)
			}
		},

		//查看
		table_show(row) {
			this.dialog.info = true
			this.$nextTick(() => {
				this.$refs.infoDialog.setData(row)
			})
		},

		upsearch() {
			this.$refs.table.upData(this.search)
		},
		cleanSearch() {
			this.search = {}
			this.$refs.table.reload(this.search)
		},
		//本地更新数据
		handleSuccess(data, mode) {
			if (mode === 'add') {
				data.id = new Date().getTime()
				this.$refs.table.tableData.unshift(data)
			} else if (mode === 'edit') {
				this.$refs.table.tableData
					.filter((item) => item.id === data.id)
					.forEach((item) => {
						Object.assign(item, data)
					})
			}
		}
	}
}
</script>

<style>
.header-btn-item {
	display: flex;
}
</style>
